﻿using System;
using System.Web;

namespace APMS.WebSite.Common
{
    /// <summary>
    /// UserProfile represents account information for currnet user in the session
    /// </summary>
    /// <version>$Revision$ $Date$</version>
    /// <history>
    /// <record>09/07/2008. raQuiam - Created this file</record>
    /// </history>
    public class UserProfile
    {
        #region Constatns
        /// <summary>
        /// Key to access instance of UserProfile object in the session
        /// </summary>
        private const string APMS_USER_PROFILE = "apms_userProfile";
        #endregion

        #region Properties
        /// <summary>
        /// An instance of UserProfile
        /// </summary>
        private static UserProfile Instance
        {
            get
            {
                // Singleton construction
                if (HttpContext.Current.Session[APMS_USER_PROFILE] == null)
                {
                    HttpContext.Current.Session[APMS_USER_PROFILE] = new UserProfile();
                }
                return HttpContext.Current.Session[APMS_USER_PROFILE] as UserProfile;
            }
        }

        private string _userName;
        public static string UserName 
        {
            get { return Instance._userName; }
            set { Instance._userName = value; }
        }
        #endregion

        #region Constructor
        /// <summary>
        /// Singleton constructor
        /// </summary>
        private UserProfile()
        {
            //HttpContext.Current.Session[APMS_USER_PROFILE] = new UserProfile();
        }
        #endregion

        #region Methods
        public static void Initialize(string userName)
        {
            Instance._userName = userName;
        }
        #endregion
    }
}
